package org.java2me.mobileboxing;

import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;

/**
 * Created by IntelliJ IDEA.
 * User: aterreno
 */
public class MobileBoxingMidlet extends MIDlet {
    private final CommandListener commandListener = new MobileBoxingCommandListener(this);
    private Scheduler scheduler;
    private MobileBoxingCanvas canvas;

    protected void startApp() throws MIDletStateChangeException {
        Display display = Display.getDisplay(this);
        canvas = new MobileBoxingCanvas(display, commandListener);
        scheduler = new Scheduler(canvas);
        display.setCurrent(canvas);
    }

    protected void pauseApp() {
        pause();
    }

    protected void destroyApp(boolean unconditional) {
    }

    public void pause() {
        scheduler.resetTimers();
        canvas.updateStatus(Status.IDLE());
    }

    public void start() {
        scheduler.start();
    }
}
